package org.pupil.config.provider;

import org.pupil.config.Properties;
import org.pupil.config.RpcProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * @Description: 服务提供方配置类
 * @Author: pupil
 * @Date: 2024/07/21 下午 2:02
 */
@Component
public class ProviderConfig {

    @Bean
    public RpcProperties rpcProperties(){
        return new RpcProperties();
    }

    @Bean
    public ProviderPostProcessor providerPostProcessor(RpcProperties rpcProperties){
        Properties.setPort(rpcProperties.getPort());
        Properties.setRegister(rpcProperties.getRegistry());
        Properties.setInvoke(rpcProperties.getInvoke());
        Properties.setSerialization(rpcProperties.getSerialization());
        Properties.setCompression(rpcProperties.getCompression());

        return new ProviderPostProcessor(rpcProperties);
    }
}
